<?php
/**
 * @author shutyuka@gmail.com
 * @modified 2011-02-20
 */
class Shops{
	
	static public $FLAG_INACTIVE = 0;
	
	static public $FLAG_UNACTIVE = 10;
	
	static public $TABLE_NAME="shops";

	static public function Create($shop) {
		$shop['create_time'] = time();
		$shop['id'] = DB::Insert(self::$TABLE_NAME, $shop);
		
		return $shop['id'];
	}
	
	static public function Update($shop) {
		Table::UpdateCache(self::$TABLE_NAME, $shop['id'], $shop);
		
		return ;
	}
	
	static public function GetAllShops(){
		$oc = array( 
			'activity' => self::$FLAG_INACTIVE
			);
		$allShops = DB::LimitQuery(self::$TABLE_NAME, array(
				'condition' => $oc,
				'order' => 'ORDER BY id ASC'
				));
		return $allShops;
	}
	
	static public function GetFistShop(){
		$oc = array( 
			'activity' => self::$FLAG_INACTIVE, 
			"first_shop = 1"
			);

		$allShops = DB::LimitQuery(self::$TABLE_NAME, array(
				'condition' => $oc,
				'order' => 'ORDER BY id ASC'
				));
		//return $allShops;
	}

	static public function SetShopUnactive($shopId) {
		if (!$shopId) 
			return array();
		Table::UpdateCache(self::$TABLE_NAME, $shopId, array(
			'activity' => self::$FLAG_UNACTIVE)
		);
		return ;
	}
	
	
	static public function SetShopInActive($shopId) {
		if (!$shopId) 
			return array();
		Table::UpdateCache(self::$TABLE_NAME, $shopId, array(
			'activity' => self::$FLAG_INACTIVE)
		);
		return ;
	}
	
}
